﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using WebAPI.Models;

namespace WebAPI.Controllers
{
    public class FeedbackMsgController : BaseApiController
    {
        [HttpPost]
        public bool Insert()
        {
            bool result = false;
            string feedbackContent = HttpContext.Current.Request.Form["feedbackContent"];
            string feedbackContractWay = HttpContext.Current.Request.Form["feedbackContractWay"];
            int userId= Convert.ToInt32(HttpContext.Current.Request.Form["userId"]);
            int feedbackType= Convert.ToInt32(HttpContext.Current.Request.Form["feedbackType"]);
            DateTime now = DateTime.Now;

            FeedbackMsg msg = new FeedbackMsg() { FeedbackContent = feedbackContent, UserId = userId, FeedbackTime = now, ContactWay = feedbackContractWay, FeedbackType= feedbackType };
            db.FeedbackMsg.Add(msg);
            int n = db.SaveChanges();
            if (n > 0)
            {
                result = true;
            }
            return result;
        }
    }
}
